package com.gmail.dmitryustimov.ms.java7.visitor.mod_reflective.example.example2;


public class CarElementDoVisitor extends Visitor {
    public void visit(Wheel wheel) {
        System.out.println("Kicking my " + wheel.getName() + " wheel");
    }

    public void visit(Engine engine) {
        System.out.println("Starting my engine");
    }

    public void visit(Body body) {
        System.out.println("Moving my body");
    }

    public void visit(Car car) {
        for(CarElement elem : car.elements) {
            try {
                visit(elem);
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            }
        }
        System.out.println("Starting my car");
    }
}
